<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/component/common.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" ></meta>
    <title>详细内容</title>
    <link rel="stylesheet" href="${frames}/css/lib/bootstrap.min.css" type="text/css" type="text/css">
    <link rel="stylesheet" href="${frames}/css/lib/bootstrap-datetimepicker.min.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/base/base.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/common.css" type="text/css">
    <link rel="stylesheet" href="${frames}/css/picker.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/select2.min.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/beautify-time.css" type="text/css">
    <link rel="stylesheet" href="${assets}/css/views/department/addDepartment.scss">
    <script src="${frames}/Chronic/laydate/laydate.js"></script>
    <%@ include file="/WEB-INF/jsp/component/commonBottom.jsp" %>
    <%--<script src="${frames}/laydate/laydate.dev.js"></script>--%>
    <script src="${assets}/bootstrapValidator/js/bootstrapValidator.js"></script>
    <script src="${assets}/bootstrapValidator/js/language/zh_CN.js"></script>
    <script src="${newframe}/js/select2.full.zh.js"></script>
    <style>
        body{
            width:760px;
            overflow:hidden;
        }
        .test{
            width:100%;
            overflow:hidden;
        }
        .test p{
            width:100%;
            line-height:100px;
            font-size:15px;
            text-align:center;
        }
        #change{
            position:fixed;
            bottom:16px;
            right:16px;
        }
        label{
            margin-left:5px;
        }
        .text_number input,selectt{
            border:1px solid #d0d0d0;
            width:135px;
            height:30px;
        }
        .title{
            line-height:25px;
            font-size:16px;
            color:#666666;
            margin-left:10px;
        }
        .title1{
            line-height:25px;
            font-size:15px;
            color:#666666;
            margin-left:17px;
            margin-top:5px;
        }
        .text_content{
            margin:20px 0;
            margin-left:18px;
        }
        .text_content div{
            width:48%;
            text-align: left;
            display: inline-block;
        }
        .text_number{
            color:#666666;
            margin-left:20px;
        }
        .bootstrapDatepickr-cal{
            top:465px !important;
        }
        #keep{
            background:#35acfd !important;
        }
        .change{
            position:fixed;
            top:60%;
            width:100%;
        }
        .btn{
            width:100px;
            line-height: 15px;
            background: #35acfd;
            color: white;
        }
        .modal-footer{
            width:255px;
            margin:0 auto;
        }
        img{
            max-width:100%;
            height:auto;
        }
        span{
            font-family: PingFang-SC-Regular;
            font-size: 16px;
            font-weight: normal;
            font-stretch: normal;
            letter-spacing: 0px;
            color: #666666;
        }
        #szyValue{
            position:absolute;
        }
        .height_unit{
            position:relative;
            left:162px;
            display:inline-block;
            text-align:center;
            line-height:30px;
        }
        #ssyValue{
            position:absolute;
        }
        #heartRate{
            position:absolute;
        }
        input,select{
            border: solid 1px #d0d0d0;
            width:210px !important;
            height:30px !important;
            vertical-align:middle;
            height:30px;
            display:inline-block !important;
        }
        .height_unit1{
            position:relative;
            left:165px;
            display:inline-block;
            text-align:center;
            line-height:30px;
        }
        h1{
            font-family: MicrosoftYaHei;
            font-size: 20px;
            font-weight: normal;
            color: #2a3137;
            margin-bottom: 26px;
            float: left;
        }
        .defualt{
            border:1px solid red;
        }
        input{
            margin-left:10px;
        }
    </style>
</head>
<body>
<div class="header">
    <h1>随诊检查记录</h1>
</div>
<div class="test">
    <span style="width:5px;padding-bottom:25px;background-color:#35acfd;display:inline-block;vertical-align:middle"></span>
    <span class="title">DXA数值</span>
    <div class="text_content">
        <div>
            <span style="width:20px;height:20px;display: inline-block;vertical-align:middle">
                <img src="../assets/images/ssy.png" alt="">
            </span>
            <span class="szyValue" style="margin-left:10px;">T-score:</span>
            <input type="text" class="form-control" id="szyValue" placeholder="请输入数字（-4~1）" onchange="changeInput(this)">
            <span class="height_unit">g/c㎡</span>
        </div>
        <div>
            <span style="width:20px;height:20px;display: inline-block;vertical-align:middle">
                <img src="../assets/images/szy.png" alt="">
            </span>
            <span class="text_number" style="margin-left:10px;">月份:</span>
            <select name="" id="month" style="margin-left:10px;">
                <option value="首次">首次</option>
                <option value="3月">3月</option>
                <option value="6月">6月</option>
                <option value="12月">12月</option>
                <option value="18月">18月</option>
                <option value="24月">24月</option>
            </select>
        </div>
    </div>
</div>
</div>
<div class="change">
    <div class="form-group submitBtn" style="text-align: center ">
        <button type="button" class="btn" data-dismiss="modal" id="closeModalButt" onclick="closeFrame()">
            关闭
        </button>
        <button type="submit" class="btn" id="keep"  onclick="keep()" style="margin-left:20px;">保存</button>
    </div>
</div>
<script>
    // 初始化
    var diseasesType = ''
    var url = ''
    var type = ""
    var idCard = '';
    var id = '';
    $(function(){
        idCard = location.search.split('?')[1].split('&')[0].split('=')[1]
        type = location.search.split('?')[1].split('&')[1].split('=')[1]
        id = location.search.split('?')[1].split('&')[2].split('=')[1]
        console.log(id)
    })
    function changeInput(e){
        if( e.value > 1 || e.value < -4 ){
            e.value = ''
            e.className = 'form-control defualt'
        }else{
            e.classList.remove("defualt");
        }
    }
    //关闭并刷新
    function closeFrame() {
        window.parent.simpleCloseModal();
    }
    function keep(){
        // 获取数据
        $('#keep').attr('disabled','disabled')
        var BMD = $('#szyValue').val();
        var options = $('#month option:selected').val()
        if( BMD > 1 || BMD < -4 ){
            BMD = '';
        }
        if( BMD === "" ){
            var inputs = $('input')
            var arr = []
            for( var a = 0; a < inputs.length; a++ ){
                if( $(inputs[a]).val() === '' ){
                    $(inputs[a]).attr('placeholder','请输入数字（-4~1）')
                    $(inputs[a]).addClass('defualt')
                    arr.push($(inputs[a]))
                }
            }
            arr[0].focus()
            $(arr[0]).removeClass('defualt')
        }else{
            $.ajax({
                url:"${URL_BONELOOSE_RESULTSAVE}",
                dataType:"json",
                type:"post",
                data:{
                    checkValue:BMD,
                    idCard:idCard,
                    testTimes:options,
                    type:type
                },
                success:function(data){
                    if( data.success ){
                        $.ajax({
                            url:'${URL_BONELOOSE_RESULTLIST}',
                            data:{
                                idCard:idCard,
                                type:type
                            },
                            dataType:'json',
                            type:'get',
                            success:function(data){
                                console.log(data)
                                var Document = parent.document.getElementById('testIframe').contentWindow;
                                var parentVM = parent.document.getElementById('testIframe').contentWindow.vm;
                                var dataList = data.dataList;
                                parentVM.score = false;
                                parentVM.testTime1 = [];
                                parentVM.checkData1 = [];
                                parentVM.reads1 = [];
                                for( var a = 0 ;a < dataList.length; a++ ){
                                    if( dataList[a].testTimes == '首次' ){
                                        parentVM.testTime1[0] = dataList[a].testTimes;
                                        parentVM.reads1[0] = dataList[a].createTime
                                        parentVM.checkData1[0] = dataList[a].checkValue
                                        console.log(parentVM.checkData1[0])
                                    }else if( dataList[a].testTimes == '3月' ){
                                        parentVM.testTime1[1] = dataList[a].testTimes;
                                        parentVM.reads1[1] = dataList[a].createTime
                                        parentVM.checkData1[1] = dataList[a].checkValue
                                    }else if( dataList[a].testTimes == '6月' ){
                                        parentVM.testTime1[2] = dataList[a].testTimes;
                                        parentVM.reads1[2] = dataList[a].createTime
                                        parentVM.checkData1[2] = dataList[a].checkValue
                                    }else if( dataList[a].testTimes == '12月' ){
                                        parentVM.testTime1[3] = dataList[a].testTimes;
                                        parentVM.reads1[3] = dataList[a].createTime
                                        parentVM.checkData1[3] = dataList[a].checkValue
                                    }else if( dataList[a].testTimes == '18月' ){
                                        parentVM.testTime1[4] = dataList[a].testTimes;
                                        parentVM.reads1[4] = dataList[a].createTime
                                        parentVM.checkData1[4] = dataList[a].checkValue
                                    }else if( dataList[a].testTimes == '24月' ){
                                        parentVM.testTime1[5] = dataList[a].testTimes;
                                        parentVM.reads1[5] = dataList[a].createTime
                                        parentVM.checkData1[5] = dataList[a].checkValue
                                    }
                                }
                                console.log(Document.document.getElementById(id))
                                var str = '';
                                var strName = '';
                                var stringData = '';
                                if( id == 'scoreBar' ){
                                    str = '腰椎score';
                                    strName = '腰椎score数值'
                                    stringData = 'score'
                                    parentVM.score = true
                                }else if( id == 'scoreBar1' ){
                                    str = '髋部score';
                                    strName = '髋部score数值'
                                    stringData = 'score1'
                                    parentVM.score1 = true
                                }else if( id == 'scoreBar2' ){
                                    str = '前臂score';
                                    strName = '前臂score数值'
                                    stringData = 'score2'
                                    parentVM.score2 = true
                                }
                                parentVM.ultData(Document.document.getElementById(id),parentVM.checkData1,parentVM.reads1,parentVM.testTime1,str,-4,1,strName,stringData)
                                window.parent.simpleCloseModal();
                            }
                        })
                    }
                }
            })
        }
    }
</script>
</body>
</html>
